package com.zhiyou100.entityclass;


import com.zhiyou100.dao.TeacherDao;

import java.io.Serializable;

/**
 * @author yang
 */
public class Student implements Serializable {

    private Long sid;
    private String sname;
    private String sex;
    private Long sage;
    private Long scid;

    public Student() {

    }

    @Override
    public String toString() {
        return "Student{" +
                "sid=" + sid +
                ", sname='" + sname + '\'' +
                ", sex='" + sex + '\'' +
                ", sage=" + sage +
                ", scid=" + scid +
                '}';
    }

    public Long getSid() {
        return sid;
    }

    public void setSid(Long sid) {
        this.sid = sid;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Long getSage() {
        return sage;
    }

    public void setSage(Long sage) {
        this.sage = sage;
    }

    public Long getScid() {
        return scid;
    }

    public void setScid(Long scid) {
        this.scid = scid;
    }

    public Student(Long sid, String sname, String sex, Long sage, Long scid) {
        this.sid = sid;
        this.sname = sname;
        this.sex = sex;
        this.sage = sage;
        this.scid = scid;
    }

    /**
     * @Description: TODO sid 是否合理
     * @name: sidFlag
     * @param: [sid]
     * @return: boolean
     * @date: 7/23/20 11:28
     * @author: yang
     */
    public boolean sidFlag(String sid) {
        boolean flag = false;
        if (sid == null || sid.length() == 0) {
            flag = false;
        } else {
            int i = Integer.parseInt(sid);
            if (i <= 0) {
                flag = false;
            } else {
                flag = true;
            }
        }
        return flag;
    }

    /**
     * @Description: TODO sname 合理性
     * @name: snameFlag
     * @param: [sname]
     * @return: boolean
     * @date: 7/23/20 11:58
     * @author: yang
     */
    public boolean snameFlag(String sname) {
        boolean flag = false;
        int max = 11;
        if (sname == null || sname.length() == 0) {
            flag = false;
        } else {
            if (sname.length() > max) {
                return false;
            } else {
                return true;
            }
        }

        return flag;
    }

    /**
     * @Description: TODO sex 合理性
     * @name: sexFlag
     * @param: [sex]
     * @return: boolean
     * @date: 7/23/20 11:59
     * @author: yang
     */
    public boolean sexFlag(String sex) {
        boolean flag = false;
        char man = 'm';
        char woman = 'w';
        if (sex == null || sex.length() == 0) {
            flag = false;
        } else {
            if (sex.length() > 1) {
                flag = false;
            } else {
                char c = sex.charAt(0);
                // m or w
                if (c != man || c != woman) {
                    // 不 m 或者 不是 w
                    flag = false;
                } else {
                    flag = true;
                }
            }
        }

        return flag;
    }

    /**
     * @Description: TODO sage 合理性
     * @name: sageFlag
     * @param: [sage]
     * @return: boolean
     * @date: 7/23/20 11:59
     * @author: yang
     */
    public boolean sageFlag(String sage) {
        boolean flag = false;
        if (sage == null || sage.length() == 0) {
            flag = false;
        } else {
            int i = Integer.parseInt(sage);
            if (i <= 0) {
                flag = false;
            } else {
                flag = true;
            }
        }


        return flag;
    }

    /**
     * @Description: TODO scid 合理性
     * @name: scidFlag
     * @param: [scid]
     * @return: boolean
     * @date: 7/23/20 11:59
     * @author: yang
     */
    public boolean scidFlag(String scid) {


        boolean flag = false;


        if (scid == null || scid.length() == 0) {
            flag = false;
        } else {
            if (new TeacherDao().theTidExist(scid)) {
                flag = true;
            } else {
                flag = false;
            }
        }

        return flag;
    }

    public static void main(String[] args) {
        String s = "w";
        //fdsfds
        //fdsfads



    }
}
